#include "Num.h"
#include "IVisitor.h"

Num::Num(const ObjectPtr& n, int type, const QString& num, int nodeId):
    exprType(nodeId),
    _n(n),
    _type(type),
    _num(num)
{
}
    
Num::~Num()
{
    
}
    
Ast::AstTypes Num::type() const
{
    return Ast::Num;
}
    

ObjectPtr Num::n()
{
    return _n;
}

void Num::setN(const ObjectPtr& n)
{
    _n = n;
}

int Num::type_()
{
    return _type;
}

void Num::setType_(int type)
{
    _type = type;
}

QString Num::num()
{
    return _num;
}

void Num::setNum(const QString& num)
{
    _num = num;
}

    
QString Num::toString() const
{
    return QString("Num[n=%1, type=%2, num=%3]").
                arg(_n ? _n->toString():"").
                arg(_type).
                arg(_num);
}
    
void Num::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitNum(node.dynamicCast<Num>());
}
    
void Num::traverse(IVisitor* visitor)
{
    if (_n != NULL)
        _n->accept(visitor, _n);
}